-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Lazy #143
base: main
Are you sure you want to change the base?
feat: Lazy #143
Conversation
|
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
this.#init = init; | ||
} | ||
|
||
#current: T | undefined = $state(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#current: T | undefined = $state(); | |
#current = $state<T>(null!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why null tho? We can do this, no?
$state()!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about the $state()!
, I've been using null!
because it will never have a type thus narrowing to the generic param but the training !
is even better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also do $state() as T
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I usually do null!
when working with like HTMLElement
or something longer than T
but moving forward I'm doing the $state()!
this.#initialized = true; | ||
}); | ||
} | ||
return this.#current as T; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.#current as T; | |
return this.#current |
No description provided.